package com.ruicar.afs.cloud.afscase.mq.receiver.processor;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruicar.afs.cloud.afscase.channel.common.Constants;
import com.ruicar.afs.cloud.afscase.channel.condition.CarDealerCondition;
import com.ruicar.afs.cloud.afscase.channel.controller.CarDealerController;
import com.ruicar.afs.cloud.afscase.channel.entity.*;
import com.ruicar.afs.cloud.afscase.channel.enums.MqTypeEnum;
import com.ruicar.afs.cloud.afscase.channel.service.*;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.common.modules.dto.mq.affiliation.AffiliationRelInfo;
import com.ruicar.afs.cloud.common.mq.rabbit.listener.AfsMqBizProcessor;
import com.ruicar.afs.cloud.common.mq.rabbit.message.MqTransCode;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author sangjian
 * @version 1.0
 * @createDate 2020-09-25
 */
@AllArgsConstructor
@Slf4j
@Component
@ConditionalOnProperty(prefix = "com.ruicar.afs.cloud.mq.rabbit", name = "enable")
public class CommomCarDealerProcessor implements AfsMqBizProcessor<CarDealerCondition> {

    private CarDealerService carDealerService;
    @Override
    public boolean processMessage(CarDealerCondition condition) throws Exception {
        MqTypeEnum mqType = condition.getMqTypeEnum();
        switch (mqType){
            case save_car:
                carDealerService.saveCommonCarDealer(condition);
                break;
            case change_status:
                carDealerService.changeStatus(condition);
                break;
        }
        return true;
    }

    @Override
    public MqTransCode getCode() {

        return MqTransCode.CHANNEL_COMMONC_CAR_DEALER_TO_CASE;
    }




}
